<?php 	 
	$productAll = $product->show_product();	  	
	if(isset($_POST['btn_choose']))
	{
		if(!isset($_POST['choose']))
		{
			
			echo "<script>alert('Please choose option!')</script>";					
		}
		else 
		{
			if($user)	
			{
				$optionID = $_POST['choose'];					
				$ipAddress=$_SERVER['REMOTE_ADDR'];
				$voteTime = date("Y-m-d H:i:s",time());
				$productID = $_GET['productID'];
				$productVote->insert_product_vote($optionID, $productID, $ipAddress, $voteTime);
				//header("Location: index.php?func=product_detail&productID=$productID");
				echo "<script>window.location.href='index.php?func=product_detail&productID=$productID'</script>";
			}else{
				echo "<script>alert('Please Login Facebook!!')</script>";
		
			}
			
			
		}		
	}
?>

	<?php 
		foreach($productAll as $product)
		{
	?>
			<form action="index.php?func=product&productID=<?php echo $product['productID']?>" method="POST" >
				<div class="products-listing">              
                	<div class ="title-pro">
               			<?php echo $product['productName']?>
					</div>
                	<div class="" style="min-height:155px">
                		<img alt="" src="<?php echo $product['proImg']?>">
                	</div>               
                 		<?php                	
                	 		include 'productOption.php';
                 		?>
                 	<input type="submit" name="btn_choose" value="Show Result" class="button mws-button blue" style="padding:4px 9px !important;">
   				</div>
   			</form>	
	<?php 
		}
	?> 	
	   			
			
	
			
	
    
